export default function formatTime(time) {
  const timestamp = +new Date() - +new Date(time);
  const month = Math.floor(timestamp / 1000 / 60 / 60 / 24 / 30);
  const week = Math.floor(timestamp / 1000 / 60 / 60 / 24 / 7);
  const day = Math.floor(timestamp / 1000 / 60 / 60 / 24);
  const hour = Math.floor(timestamp / 1000 / 60 / 60 % 24);
  const minute = Math.floor(timestamp / 1000 / 60 % 60);
  const second = Math.floor(timestamp / 1000 % 60);
  if (month >= 1) return `${month} 个月前`;
  if (week >= 1) return `${week} 周前`;
  if (day >= 1) return `${day} 天前`;
  if (hour >= 1) return `${hour} 小时前`;
  if (minute >= 1) return `${minute} 分钟前`;
  if (second >= 30) return `${second} 秒前`;
  return '刚刚';
}
